// BitManipulation.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int insertNumber(int from, int to, int start, int end)
{
    from = from << start;
    to = to & (-1 << end);
    return to | from;
}

void testInsertNumber()
{
    //5.1 You are given two 32-bit numbers, N and M, and tow bit postions, i and j. Write a method to insert
    //M into N such that M starts at bit j and ends at bit i. You can assume that the bits j through i have 
    //enough space to fix all the M. That is M = 10011, you can assume that there are at least 5 bits between
    //j and i. You would not, for example, have j = 3 and i = , because M could not fully fit between bit 3 
    //and bit 2.
    auto x = insertNumber(0x13, 0x400, 2, 6);
    cout << x << endl;
}

void printBinaryRepresentation(double input)
{
}

void testPringBinaryRepresentation()
{
    //Given a real number between 0 and 1 (e.g. 0.72) that is passed in as double, print the binary 
    //representation. If the number cannot be represented accurately in binary with at most 32 character,
    //pint "ERROR".
    printBinaryRepresentation(0.25);
}

int _tmain(int argc, _TCHAR* argv[])
{
    testInsertNumber();
    testPringBinaryRepresentation();
    cin.get();
	return 0;
}

